from pyecharts import options as opts
from pyecharts.charts import Bar

# 数据
values = [437, 799, 162, 9, 46, 17]
categories = ["销售部", "研发部", "信息技术部", "行政部", "人力资源部", "财务部"]

# 创建条形图
bar = (
    Bar(init_opts=opts.InitOpts(bg_color="#1D244A"))
    .add_xaxis(categories)
    .add_yaxis("", values, category_gap="50%", color="#7AD5FE")
    .reversal_axis()
    .set_global_opts(
        title_opts=opts.TitleOpts(title="部门", pos_left="center",
                                  title_textstyle_opts=opts.TextStyleOpts(color="white")),
        xaxis_opts=opts.AxisOpts(
            axislabel_opts=opts.LabelOpts(is_show=False),
            axisline_opts=opts.AxisLineOpts(is_show=False),
            axistick_opts=opts.AxisTickOpts(is_show=False),
            splitline_opts=opts.SplitLineOpts(is_show=False)
        ),
        yaxis_opts=opts.AxisOpts(
            axislabel_opts=opts.LabelOpts(color="white"),
            axisline_opts=opts.AxisLineOpts(is_show=False),
            axistick_opts=opts.AxisTickOpts(is_show=False),
            splitline_opts=opts.SplitLineOpts(is_show=False)
        ),
        legend_opts=opts.LegendOpts(is_show=False),
    )
    .set_series_opts(
        label_opts=opts.LabelOpts(position="right", color="white", formatter="{c}")
    )
)
bar.render("部门.html")
